projects
/
project
/
rpcd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
efbcedb
)
file: patch process stdin to /dev/null
author
Jo-Philipp Wich
<
[email protected]
>
Fri, 21 Dec 2018 08:09:55 +0000
(09:09 +0100)
committer
Jo-Philipp Wich
<
[email protected]
>
Tue, 26 May 2020 14:21:13 +0000
(16:21 +0200)
This prevents broken pipe errors in executed child processes that
attempt to access stdin.
Suggested-by: Vytautas Virvičius <
[email protected]
>
Signed-off-by: Jo-Philipp Wich <
[email protected]
>
(cherry picked from commit
67118a6b334cd50c9f39a0c04506befd49bf592a
)
file.c
patch
|
blob
|
history
diff --git
a/file.c
b/file.c
index 09b4afd6e97cc5125bfca9beed2f66bc2193119a..23deb73e2470f6ccbe3f074db79a9930e200a324 100644
(file)
--- a/
file.c
+++ b/
file.c
@@
-597,6
+597,7
@@
rpc_file_exec_run(const char *cmd,
{
pid_t pid;
+ int devnull;
int opipe[2];
int epipe[2];
@@
-629,10
+630,16
@@
rpc_file_exec_run(const char *cmd,
case 0:
uloop_done();
+ devnull = open("/dev/null", O_RDWR);
+
+ if (devnull == -1)
+ return UBUS_STATUS_UNKNOWN_ERROR;
+
+ dup2(devnull, 0);
dup2(opipe[1], 1);
dup2(epipe[1], 2);
- close(
0
);
+ close(
devnull
);
close(opipe[0]);
close(opipe[1]);
close(epipe[0]);